From: Jo-Philipp Wich Date: Sat, 21 Sep 2019 08:55:54 +0000 (+0200) Subject: luci-base: tie cached system features to user session X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=6dba41cadc82785f23773f219d30403f6b12956e;p=project%2Fluci.git luci-base: tie cached system features to user session Store the cached system feature flags keyed by the current session id, this ensures that the features are refreshed on login. Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 1d349ebc17..4e3c8445a9 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -823,9 +823,14 @@ }, probeSystemFeatures: function() { + var sessionid = classes.rpc.getSessionID(); + if (sysFeatures == null) { try { - sysFeatures = JSON.parse(window.sessionStorage.getItem('sysFeatures')); + var data = JSON.parse(window.sessionStorage.getItem('sysFeatures')); + + if (this.isObject(data) && this.isObject(data[sessionid])) + sysFeatures = data[sessionid]; } catch (e) {} } @@ -837,7 +842,10 @@ expect: { '': {} } })().then(function(features) { try { - window.sessionStorage.setItem('sysFeatures', JSON.stringify(features)); + var data = {}; + data[sessionid] = features; + + window.sessionStorage.setItem('sysFeatures', JSON.stringify(data)); } catch (e) {}